<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="format-detection" content="telephone=no"/>
<meta name="wap-font-scale" content="no">
<meta name="renderer" content="webkit">
<title>AutoCode</title>
<link rel="shortcut icon" href="/favicon.ico" />
<script src="/links/jquery/jquery-3.5.1.min.js"></script>
<script src="/links/polyfill.min.js"></script>
<script src="/links/axios/axios.min.js"></script>
<script src="/links/vue/vue.min.js"></script>
<script src="/links/element-ui/index.js"></script>
<script src="/links/dayjs.min.js"></script>
<script src="/links/echarts/echarts.js"></script>
<script src="/links/JsBarcode.all.js"></script>
<script src="/links/qrcode.min.js"></script>
<script src="/links/layer/layer.js"></script>
<script src="/links/crypto/crypto-js.js"></script>
<script src="/js/dragController.js"></script>
<script src="/js/HttpApi.js"></script>
<script src="/js/AutoCode.js"></script>
<link href="/links/element-ui/theme/index.css" rel="stylesheet"/>
<link href="/css/default.css" rel="stylesheet"/>
<link href="/css/dragController.css" rel="stylesheet"/>
    
    <style>
        
    </style>
</head>
<body>
<div id="app"  class="box " >
<div class="left " style="width:400px;">
<div class="flex ac-tree-head ac-tree-head-default-line">
    <div class="ac-tree-title">{{tableTree.title}}</div>
    <div class="ac-tree-oper">
        <el-form :inline="true" label-position="left" :model="tableTree.operData" size="mini" class="searchForm" @submit.native.prevent="tableTree_load">
<el-form-item v-if="tableTree.operVisible.buttonC"><el-button size="medium"  v-if="tableTree.operVisible.buttonC" @click="tableTree_syncFromServer()" :disabled="tableTree.operDisabled.buttonC"  type="text"     native-type="button">从设计器同步</el-button>
</el-form-item>
<el-form-item v-if="tableTree.operVisible.buttonQ"><el-button size="medium"  v-if="tableTree.operVisible.buttonQ" @click="tableTree_load()" :disabled="tableTree.operDisabled.buttonQ" icon="null" type="text"     native-type="button">刷新(R)</el-button>
</el-form-item>
<el-form-item v-if="tableTree.operVisible.type"><el-dropdown @command="tableTree_command">
    <span class="el-dropdown-link">
    	<el-button type="text" size="medium" >相关操作<i class="el-icon-arrow-down"></i></el-button>
    </span>
    <el-dropdown-menu slot="dropdown">
        <el-dropdown-item :command="{'type':'addCategory'}">添加目录</el-dropdown-item>
<el-dropdown-item :command="{'type':'addTable'}">添加新表</el-dropdown-item>
<el-dropdown-item :command="{'type':'syncFromDb'}">从数据库同步</el-dropdown-item>
    </el-dropdown-menu>
</el-dropdown>
</el-form-item>

</el-form>

    </div>
</div>
<div style="padding:5px 10px;">
    <el-input size="mini" placeholder="输入关键字进行过滤" v-model="tableTree.filterValue"></el-input>
</div>
<div class="ac-tree-content2">
    <el-tree ref="tableTree" :data="tableTree.data"
    :expand-on-click-node="false" node-key="id" empty-text="内容为空"
    highlight-current :current-node-key="tableTree.currentNodeKey"  
       
    :filter-node-method="tableTree_filterNodeMethod"
      
    draggable :allow-drag="tableTree_allowDrag" :allow-drop="tableTree_allowDrop" @node-drop="tableTree_nodeDrop"
    
    @current-change="tableTree_currentChange"
    >
    <span class="custom-tree-node" slot-scope="{ node, data }">
    <span>
        <tempalte v-if="data.type=='category'">
            <i class="el-icon-folder"></i> {{ data.code }}【{{ data.label }}】
        </tempalte>
        <tempalte v-else>
            <i class="el-icon-document"></i> {{ data.tableName }}
        </tempalte>
    </span>
    <span>
        <el-dropdown size="small" @command="tableTree_treeCommand">
            <el-link icon="el-icon-more"></el-link>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item v-if="data.type=='category'" :command="{'flag':'editCategory','nodeData':data}">编辑目录</el-dropdown-item>
                <el-dropdown-item v-if="data.type=='category'" :command="{'flag':'delCategory','nodeData':data}">删除目录</el-dropdown-item>
                <el-dropdown-item v-if="data.type=='table'" :command="{'flag':'syncFromDb','nodeData':data}">从数据库同步</el-dropdown-item>
                <el-dropdown-item v-if="data.type=='table'" :command="{'flag':'delTable','nodeData':data}">删除表</el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
    </span>
</span>
</el-tree>

</div>
</div>
<div class="resize"></div>
<div class="right " style="width:calc(100% - 402px);">
<div class="box"><div class="topBox " style="height:250px;">
 <div class="flex ac-form-head ac-form-head-default-line">
    <div class="ac-form-title"></div>
    <div class="ac-form-oper"><el-form :inline="true" label-position="left" :model="tableInfo.operData" size="mini" class="searchForm" @submit.native.prevent="tableInfo_load">
<el-form-item v-if="tableInfo.operVisible.type"><template>
    <el-tag type="success"  effect="dark" v-if="tableInfo.data.isSync=='Y'">已同步</el-tag>
    <el-tag type="danger"  effect="dark" v-else>未同步</el-tag>
</template></el-form-item>
<el-form-item v-if="tableInfo.operVisible.buttonC"><el-button size="mini"  v-if="tableInfo.operVisible.buttonC" @click="tableInfo_syncFromServer()" :disabled="tableInfo.operDisabled.buttonC"  type="primary"     native-type="button">从设计器同步</el-button>
</el-form-item>
<el-form-item v-if="tableInfo.operVisible.syncServer"><el-button size="mini"  v-if="tableInfo.operVisible.syncServer" @click="tableInfo_syncToServer()" :disabled="tableInfo.operDisabled.syncServer"  type="warning"     native-type="button">同步到设计器</el-button>
</el-form-item>

</el-form>
</div>
</div>
<div class="ac-form-content">
    <el-form class="ac-el-form"    label-width="80px" label-position="right"
     size="mini" ref="tableInfo" :model="tableInfo.data" :rules="tableInfo.rules"  
     :disabled="tableInfo.disabled" @submit.native.prevent>
    <el-row><el-col :span=12 v-if="tableInfo.itemVisible.tableName">
    <el-form-item prop="tableName" label="表名">
        
<el-input type="text" size="mini"  v-model="tableInfo.data.tableName" placeholder="表名" :disabled="tableInfo.editorForm || tableInfo.itemDisabled.tableName" @change="tableInfo_change('tableName',tableInfo.data)"   ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=12 v-if="tableInfo.itemVisible.code">
    <el-form-item prop="code" label="代码标识">
        
<el-input type="text" size="mini"  v-model="tableInfo.data.code" placeholder="代码标识" :disabled="tableInfo.editorForm || tableInfo.itemDisabled.code" @change="tableInfo_change('code',tableInfo.data)"   ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=12 v-if="tableInfo.itemVisible.remarks">
    <el-form-item prop="remarks" label="中文描述">
        
<el-input type="text" size="mini"  v-model="tableInfo.data.remarks" placeholder="中文描述" :disabled="tableInfo.itemDisabled.remarks" @change="tableInfo_change('remarks',tableInfo.data)"   ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=12 v-if="tableInfo.itemVisible.categoryCode">
    <el-form-item prop="categoryCode" label="归属目录">
        <el-select v-model="tableInfo.data.categoryCode"  placeholder="归属目录" size="mini" :disabled="tableInfo.itemDisabled.categoryCode" clearable     @change="tableInfo_change('categoryCode',tableInfo.data)" >
   <el-option v-for="dict in customOptions.tableCategory" :label="dict.label" :value="dict.value"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableInfo.itemVisible.orderColumn">
    <el-form-item prop="orderColumn" label="排序信息">
        
<el-input type="text" size="mini"  v-model="tableInfo.data.orderColumn" placeholder="排序信息" :disabled="tableInfo.itemDisabled.orderColumn" @change="tableInfo_change('orderColumn',tableInfo.data)"   ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableInfo.itemVisible.selectColumn">
    <el-form-item prop="selectColumn" label="默认查询">
        
<el-input type="text" size="mini"  v-model="tableInfo.data.selectColumn" placeholder="默认查询" :disabled="tableInfo.itemDisabled.selectColumn" @change="tableInfo_change('selectColumn',tableInfo.data)"   ></el-input>

        
    </el-form-item>
</el-col>
</el-row>
 </el-form>

</div>
</div>
<div class="move"></div>
<div class="downBox " style="height:calc(100% - 252px);">
<el-tabs type="border-card" v-model="page.tabs" class=""  >
<el-tab-pane class="" label="字段信息" name="tab1" :disabled="tabDisabled.tab1" v-if="tabVisible.tab1" >
<div class="flex ac-table-head">
    <div class="ac-table-oper"><el-button size="medium"  v-if="tableFileds.operVisible.buttonA" @click="tableFileds_openTableFieldAdd()" :disabled="tableFileds.operDisabled.buttonA"  type="text"     native-type="button">添加(A)</el-button>
<el-button size="medium"  v-if="tableFileds.operVisible.buttonD" @click="tableFileds_delete()" :disabled="tableFileds.operDisabled.buttonD"  type="text"     native-type="button">删除(D)</el-button>
<el-button size="medium"  v-if="tableFileds.operVisible.buttonE" @click="tableFileds_editTableFieldAdd()" :disabled="tableFileds.operDisabled.buttonE"  type="text"     native-type="button">编辑(E)</el-button>
<el-button size="medium"  v-if="tableFileds.operVisible.C" @click="tableFileds_sort()" :disabled="tableFileds.operDisabled.C"  type="text"     native-type="button">更新排序</el-button>
</div>
    <div></div>
</div>
<div class="ac-table-content">
    <el-table row-key="id" highlight-current-row stripe show-header    border  
    :data="tableFileds.data" size="mini" ref="tableFileds"
       
    height="100%"
    @current-change="tableFileds_currentChange">
    <el-table-column prop="sortNo" label="序号" width="70"   align="center" sortable  class-name="editorCell">
   <template slot-scope="scope">
        <el-input-number size="small" v-model="scope.row.sortNo" :min="0"  :precision="0" :step="1"   :controls="false"  @change="tableFileds_change('sortNo',scope.row)"></el-input-number>

   </template>
</el-table-column>
<el-table-column prop="name" label="字段名称"    align="left" sortable  >
   <template slot-scope="scope">
        {{scope.row.name}}
   </template>
</el-table-column>
<el-table-column prop="remarks" label="字段说明"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.remarks}}
   </template>
</el-table-column>
<el-table-column prop="type" label="字段类型"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.type}}
   </template>
</el-table-column>
<el-table-column prop="length" label="字段长度"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.length}}
   </template>
</el-table-column>
<el-table-column prop="scale" label="小数位数"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.scale}}
   </template>
</el-table-column>
<el-table-column prop="isnullable" label="允许空值"    align="center"   class-name="editorCell">
   <template slot-scope="scope">
        <el-checkbox  v-model="scope.row.isnullable"  size="small"  true-label="Y"  false-label="N" disabled ></el-checkbox>

   </template>
</el-table-column>
<el-table-column prop="primaryKey" label="主键"    align="center"   class-name="editorCell">
   <template slot-scope="scope">
        <el-checkbox  v-model="scope.row.primaryKey"  size="small"  true-label="Y"  false-label="N" disabled ></el-checkbox>

   </template>
</el-table-column>
<el-table-column prop="defaultvalue" label="默认值"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.defaultvalue}}
   </template>
</el-table-column>

</el-table>

</div>
          
</el-tab-pane>
<el-tab-pane class="" label="子表信息" name="tab2" :disabled="tabDisabled.tab2" v-if="tabVisible.tab2" >
<div class="flex ac-table-head">
    <div class="ac-table-oper"><el-button size="medium"  v-if="tableRef.operVisible.buttonA" @click="tableRef_openTableRefAdd()" :disabled="tableRef.operDisabled.buttonA"  type="text"     native-type="button">添加(A)</el-button>
<el-button size="medium"  v-if="tableRef.operVisible.buttonD" @click="tableRef_delete()" :disabled="tableRef.operDisabled.buttonD"  type="text"     native-type="button">删除(D)</el-button>
</div>
    <div></div>
</div>
<div class="ac-table-content">
    <el-table row-key="id" highlight-current-row stripe show-header    border  
    :data="tableRef.data" size="mini" ref="tableRef"
       
    height="100%"
    @current-change="tableRef_currentChange">
    <el-table-column type="index" width="50" label="序号"></el-table-column>
<el-table-column prop="fkTable" label="子表名称"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.fkTable}}
   </template>
</el-table-column>
<el-table-column prop="fkField" label="子表字段"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.fkField}}
   </template>
</el-table-column>
<el-table-column prop="pkField" label="关联字段"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.pkField}}
   </template>
</el-table-column>
<el-table-column prop="deleteRule" label="级联删除"    align="center"   class-name="editorCell">
   <template slot-scope="scope">
        <el-checkbox  v-model="scope.row.deleteRule"  size="small"  true-label="Y"  false-label="N"  @change="tableRef_change('deleteRule',scope.row)"></el-checkbox>

   </template>
</el-table-column>

</el-table>

</div>
          
</el-tab-pane>
<el-tab-pane class="" label="处理规则" name="tab4" :disabled="tabDisabled.tab4" v-if="tabVisible.tab4" >
<div class="box"><div class="left " style="width:400px;">
<div class="flex ac-table-head">
    <div class="ac-table-oper"><el-form :inline="true" label-position="left" :model="tableRules.operData" size="mini" class="searchForm" @submit.native.prevent="tableRules_load">
<el-form-item v-if="tableRules.operVisible.type"><el-dropdown @command="tableRules_addYsRule">
    <span class="el-dropdown-link">
    	<el-button type="text" size="medium" >添加规则<i class="el-icon-arrow-down"></i></el-button>
    </span>
    <el-dropdown-menu slot="dropdown">
        <el-dropdown-item :command="{'ruleGroup':'1','ruleType':'11'}">自增字段</el-dropdown-item>
<el-dropdown-item :command="{'ruleGroup':'1','ruleType':'12'}">唯一性约束</el-dropdown-item>
<el-dropdown-item :command="{'ruleGroup':'2','ruleType':'21'}">禁止删除</el-dropdown-item>
<!-- <el-dropdown-item :command="{'ruleGroup':'3','ruleType':'31'}">默认条件</el-dropdown-item>-->
<el-dropdown-item :command="{'ruleGroup':'3','ruleType':'32'}">模糊匹配</el-dropdown-item>
<el-dropdown-item :command="{'ruleGroup':'4','ruleType':'41'}">结果转换</el-dropdown-item>
    </el-dropdown-menu>
</el-dropdown>
</el-form-item>
<el-form-item v-if="tableRules.operVisible.buttonD"><el-button size="medium"  v-if="tableRules.operVisible.buttonD" @click="tableRules_delete()" :disabled="tableRules.operDisabled.buttonD"  type="text"     native-type="button">删除(D)</el-button>
</el-form-item>

</el-form>
</div>
    <div></div>
</div>
<div class="ac-table-content">
    <el-table row-key="id" highlight-current-row stripe show-header    border  
    :data="tableRules.data" size="mini" ref="tableRules"
       
    height="100%"
    @current-change="tableRules_currentChange">
    <el-table-column type="index" width="50" label="序号"></el-table-column>
<el-table-column prop="ruleType" label="规则类型"    align="left"   >
   <template slot-scope="scope">
        <template v-if="scope.row.ruleType=='11'">自增字段</template><template v-else-if="scope.row.ruleType=='12'">唯一性约束</template><template v-else-if="scope.row.ruleType=='21'">禁止删除</template><template v-else-if="scope.row.ruleType=='32'">模糊检索</template><template v-else-if="scope.row.ruleType=='41'">结果转换</template><template v-else-if="scope.row.ruleType=='31'">默认条件</template><template v-else>{{scope.row.ruleType}}</template>
   </template>
</el-table-column>
<el-table-column prop="fieldName" label="规则字段"    align="left"   >
   <template slot-scope="scope">
        {{scope.row.fieldName}}
   </template>
</el-table-column>

</el-table>

</div>
          
</div>
<div class="resize"></div>
<div class="right " style="width:calc(100% - 402px);">
<el-form class="ac-el-form"    label-width="80px" label-position="right"
     size="mini" ref="tableRuleDetail" :model="tableRuleDetail.data" :rules="tableRuleDetail.rules"  
     :disabled="tableRuleDetail.disabled" @submit.native.prevent>
    <el-row><el-col :span=24 v-if="tableRuleDetail.itemVisible.ruleType">
    <el-form-item prop="ruleType" label="规则类型">
        <el-select v-model="tableRuleDetail.data.ruleType"  placeholder="规则类型" size="mini" :disabled="tableRuleDetail.editorForm || tableRuleDetail.itemDisabled.ruleType" clearable     @change="tableRuleDetail_change('ruleType',tableRuleDetail.data)" >
   <el-option label="自增字段" value="11"></el-option><el-option label="唯一性约束" value="12"></el-option><el-option label="格式字段" value="13"></el-option><el-option label="禁止删除" value="21"></el-option><el-option label="默认条件" value="31"></el-option><el-option label="模糊检索" value="32"></el-option><el-option label="结果转换" value="41"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRuleDetail.itemVisible.fieldName">
    <el-form-item prop="fieldName" label="规则字段">
        <el-select v-model="tableRuleDetail.data.fieldName"  placeholder="规则字段" size="mini" :disabled="tableRuleDetail.itemDisabled.fieldName" clearable     @change="tableRuleDetail_change('fieldName',tableRuleDetail.data)" >
   <el-option v-for="dict in customOptions.tableFields" :label="dict.label" :value="dict.value"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRuleDetail.itemVisible.keyWord">
    <el-form-item prop="keyWord" label="匹配字段">
        
<el-input type="text" size="mini"  v-model="tableRuleDetail.data.keyWord" placeholder="匹配字段" :disabled="tableRuleDetail.itemDisabled.keyWord" @change="tableRuleDetail_change('keyWord',tableRuleDetail.data)"   ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRuleDetail.itemVisible.refColumn">
    <el-form-item prop="refColumn" label="关联字段">
        <el-select v-model="tableRuleDetail.data.refColumn"  placeholder="关联字段" size="mini" :disabled="tableRuleDetail.itemDisabled.refColumn" clearable multiple    @change="tableRuleDetail_change('refColumn',tableRuleDetail.data)" >
   <el-option v-for="dict in customOptions.tableFields" :label="dict.label" :value="dict.value"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRuleDetail.itemVisible.matchUl">
    <el-form-item prop="matchUl" label="大小写">
        <el-select v-model="tableRuleDetail.data.matchUl"  placeholder="大小写" size="mini" :disabled="tableRuleDetail.itemDisabled.matchUl" clearable     @change="tableRuleDetail_change('matchUl',tableRuleDetail.data)" >
   <el-option label="区分" value="UL"></el-option><el-option label="全部转大写" value="U"></el-option><el-option label="全部转小写" value="L"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRuleDetail.itemVisible.resultType">
    <el-form-item prop="resultType" label="结果类型">
        <el-select v-model="tableRuleDetail.data.resultType"  placeholder="结果类型" size="mini" :disabled="tableRuleDetail.itemDisabled.resultType" clearable     @change="tableRuleDetail_change('resultType',tableRuleDetail.data)" >
   <el-option label="字符串数组" value="StrArray"></el-option><el-option label="整形数组" value="IntArray"></el-option><el-option label="JSON数组" value="JSONArray"></el-option><el-option label="JSON对象" value="JSONObject"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRuleDetail.itemVisible.defaultValue">
    <el-form-item prop="defaultValue" label="默认值">
        
<el-input type="text" size="mini"  v-model="tableRuleDetail.data.defaultValue" placeholder="默认值" :disabled="tableRuleDetail.itemDisabled.defaultValue" @change="tableRuleDetail_change('defaultValue',tableRuleDetail.data)"   ></el-input>

        
    </el-form-item>
</el-col>
</el-row><el-row><el-form-item prop="gszd" label="格式字段">
    <el-input v-model="tableRuleDetail.data.defaultValue" @change="tableRuleDetail_change('defaultValue')" size="mini"></el-input>
</el-form-item>
</el-row>
 </el-form>

</div>
</div>
</el-tab-pane>

</el-tabs>

</div>
</div>
</div>

<el-dialog :visible.sync="tableAdd.visible" :title="tableAdd.title"
            width="50%"
                
            :close-on-click-modal="false"
            :close-on-press-escape="false">
            <div style="width:100%;">
                <el-form class=""    label-width="80px" label-position="right"
     size="mini" ref="tableAdd" :model="tableAdd.data" :rules="tableAdd.rules"  
     :disabled="tableAdd.disabled" @submit.native.prevent>
    <el-row><el-col :span=24 v-if="tableAdd.itemVisible.tableName">
    <el-form-item prop="tableName" label="表名">
        
<el-input type="text" size="mini"  v-model="tableAdd.data.tableName" placeholder="表名" :disabled="tableAdd.itemDisabled.tableName"  @keyup.enter.native="tableAdd_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableAdd.itemVisible.remarks">
    <el-form-item prop="remarks" label="中文描述">
        
<el-input type="text" size="mini"  v-model="tableAdd.data.remarks" placeholder="中文描述" :disabled="tableAdd.itemDisabled.remarks"  @keyup.enter.native="tableAdd_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableAdd.itemVisible.categoryCode">
    <el-form-item prop="categoryCode" label="归属目录">
        <el-select v-model="tableAdd.data.categoryCode"  placeholder="归属目录" size="mini" :disabled="tableAdd.itemDisabled.categoryCode" clearable      @keyup.enter.native="tableAdd_dialogOk">
   <el-option v-for="dict in customOptions.tableCategory" :label="dict.label" :value="dict.value"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableAdd.itemVisible.code">
    <el-form-item prop="code" label="代码标识">
        
<el-input type="text" size="mini"  v-model="tableAdd.data.code" placeholder="代码标识" :disabled="tableAdd.itemDisabled.code"  @keyup.enter.native="tableAdd_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
</el-row>
 </el-form>

            </div>
            <div class="dialog-footer" slot="footer">    <el-button size="mini" @click="tableAdd_dialogOk()"  type="primary"      native-type="button">确 定</el-button>
    <el-button size="medium" @click="tableAdd_dialogCancel()"  type="text"      native-type="button">取 消</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="tableRefAdd.visible" :title="tableRefAdd.title"
            width="50%"
                
            :close-on-click-modal="false"
            :close-on-press-escape="false">
            <div style="width:100%;">
                <el-form class=""    label-width="80px" label-position="right"
     size="mini" ref="tableRefAdd" :model="tableRefAdd.data" :rules="tableRefAdd.rules"  
     :disabled="tableRefAdd.disabled" @submit.native.prevent>
    <el-row><el-col :span=24 v-if="tableRefAdd.itemVisible.fkTable">
    <el-form-item prop="fkTable" label="关联表">
        <el-select v-model="tableRefAdd.data.fkTable"  placeholder="关联表" size="mini" :disabled="tableRefAdd.itemDisabled.fkTable" clearable   filterable default-first-option @change="tableRefAdd_change('fkTable',tableRefAdd.data)" @keyup.enter.native="tableRefAdd_dialogOk">
   <el-option v-for="dict in customOptions.fkTable" :label="dict.label" :value="dict.value"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRefAdd.itemVisible.fkField">
    <el-form-item prop="fkField" label="关联字段">
        <el-select v-model="tableRefAdd.data.fkField"  placeholder="关联字段" size="mini" :disabled="tableRefAdd.itemDisabled.fkField" clearable     @change="tableRefAdd_change('fkField',tableRefAdd.data)" @keyup.enter.native="tableRefAdd_dialogOk">
   <el-option v-for="dict in customOptions.fkField" :label="dict.label" :value="dict.value"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRefAdd.itemVisible.pkField">
    <el-form-item prop="pkField" label="主表字段">
        <el-select v-model="tableRefAdd.data.pkField"  placeholder="主表字段" size="mini" :disabled="tableRefAdd.itemDisabled.pkField" clearable     @change="tableRefAdd_change('pkField',tableRefAdd.data)" @keyup.enter.native="tableRefAdd_dialogOk">
   <el-option v-for="dict in customOptions.pkField" :label="dict.label" :value="dict.value"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableRefAdd.itemVisible.deleteRule">
    <el-form-item prop="deleteRule" label="级联删除">
        <el-checkbox  v-model="tableRefAdd.data.deleteRule"  size="mini"  true-label="Y"  false-label="N" :disabled="tableRefAdd.itemDisabled.deleteRule" @change="tableRefAdd_change('deleteRule',tableRefAdd.data)" @keyup.enter.native="tableRefAdd_dialogOk"></el-checkbox>

        
    </el-form-item>
</el-col>
</el-row>
 </el-form>

            </div>
            <div class="dialog-footer" slot="footer">    <el-button size="mini" @click="tableRefAdd_dialogOk()"  type="primary"      native-type="button">确 定</el-button>
    <el-button size="medium" @click="tableRefAdd_dialogCancel()"  type="text"      native-type="button">取 消</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="tableCategory.visible" :title="tableCategory.title"
            width="50%"
                
            :close-on-click-modal="false"
            :close-on-press-escape="false">
            <div style="width:100%;">
                <el-form class=""    label-width="80px" label-position="right"
     size="mini" ref="tableCategory" :model="tableCategory.data" :rules="tableCategory.rules"  
     :disabled="tableCategory.disabled" @submit.native.prevent>
    <el-row><el-col :span=24 v-if="tableCategory.itemVisible.code">
    <el-form-item prop="code" label="目录编码">
        
<el-input type="text" size="mini"  v-model="tableCategory.data.code" placeholder="目录编码" :disabled="tableCategory.editorForm || tableCategory.itemDisabled.code"  @keyup.enter.native="tableCategory_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableCategory.itemVisible.label">
    <el-form-item prop="label" label="目录名称">
        
<el-input type="text" size="mini"  v-model="tableCategory.data.label" placeholder="目录名称" :disabled="tableCategory.itemDisabled.label"  @keyup.enter.native="tableCategory_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
</el-row>
 </el-form>

            </div>
            <div class="dialog-footer" slot="footer">    <el-button size="mini" @click="tableCategory_dialogOk()"  type="primary"      native-type="button">确 定</el-button>
    <el-button size="medium" @click="tableCategory_dialogCancel()"  type="text"      native-type="button">取 消</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="tableFieldAdd.visible" :title="tableFieldAdd.title"
            width="50%"
                
            :close-on-click-modal="false"
            :close-on-press-escape="false">
            <div style="width:100%;">
                <el-form class=""    label-width="80px" label-position="right"
     size="mini" ref="tableFieldAdd" :model="tableFieldAdd.data" :rules="tableFieldAdd.rules"  
     :disabled="tableFieldAdd.disabled" @submit.native.prevent>
    <el-row><el-col :span=24 v-if="tableFieldAdd.itemVisible.name">
    <el-form-item prop="name" label="字段名称">
        
<el-input type="text" size="mini"  v-model="tableFieldAdd.data.name" placeholder="字段名称" :disabled="tableFieldAdd.itemDisabled.name"  @keyup.enter.native="tableFieldAdd_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableFieldAdd.itemVisible.remarks">
    <el-form-item prop="remarks" label="字段说明">
        
<el-input type="text" size="mini"  v-model="tableFieldAdd.data.remarks" placeholder="字段说明" :disabled="tableFieldAdd.itemDisabled.remarks"  @keyup.enter.native="tableFieldAdd_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableFieldAdd.itemVisible.type">
    <el-form-item prop="type" label="类型">
        <el-select v-model="tableFieldAdd.data.type"  placeholder="类型" size="mini" :disabled="tableFieldAdd.itemDisabled.type" clearable      @keyup.enter.native="tableFieldAdd_dialogOk">
   <el-option label="VARCHAR" value="VARCHAR"></el-option><el-option label="CHAR" value="CHAR"></el-option><el-option label="INT" value="INT"></el-option><el-option label="DECIMAL" value="DECIMAL"></el-option><el-option label="DATETIME" value="DATETIME"></el-option><el-option label="TEXT" value="TEXT"></el-option><el-option label="LONGBLOB" value="LONGBLOB"></el-option><el-option label="TIMESTAMP" value="TIMESTAMP"></el-option>
</el-select>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableFieldAdd.itemVisible.length">
    <el-form-item prop="length" label="字段长度">
        <el-input-number size="mini" v-model="tableFieldAdd.data.length" placeholder="字段长度"  :disabled="tableFieldAdd.itemDisabled.length" :min="0"  :precision="0" :step="1"   :controls="false" ></el-input-number>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableFieldAdd.itemVisible.scale">
    <el-form-item prop="scale" label="小数位数">
        <el-input-number size="mini" v-model="tableFieldAdd.data.scale" placeholder="小数位数"  :disabled="tableFieldAdd.itemDisabled.scale" :min="0"   :step="1"   :controls="false" ></el-input-number>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableFieldAdd.itemVisible.defaultvalue">
    <el-form-item prop="defaultvalue" label="默认值">
        
<el-input type="text" size="mini"  v-model="tableFieldAdd.data.defaultvalue" placeholder="默认值" :disabled="tableFieldAdd.itemDisabled.defaultvalue"  @keyup.enter.native="tableFieldAdd_dialogOk"  ></el-input>

        
    </el-form-item>
</el-col>
<el-col :span=24 v-if="tableFieldAdd.itemVisible.isnullable">
    <el-form-item prop="isnullable" label="允许空值">
        <el-checkbox  v-model="tableFieldAdd.data.isnullable"  size="mini"  true-label="Y"  false-label="N" :disabled="tableFieldAdd.itemDisabled.isnullable"  @keyup.enter.native="tableFieldAdd_dialogOk"></el-checkbox>

        
    </el-form-item>
</el-col>
</el-row>
 </el-form>

            </div>
            <div class="dialog-footer" slot="footer">    <el-button size="mini" @click="tableFieldAdd_dialogOk()"  type="primary"      native-type="button">确 定</el-button>
    <el-button size="medium" @click="tableFieldAdd_dialogCancel()"  type="text"      native-type="button">取 消</el-button>
</div>
</el-dialog>


</div>

</body>
<script th:inline="javascript">
    let vm = new Vue({
            el: '#app',
            data() {
                return {"tableRef":{"title":"子表信息","currentRow":{},"data":[],"expandRowKeys":[],"pagingData":{},"operData":{},"operVisible":{"buttonA":true,"buttonD":true},"operDisabled":{},"rawData":[],"itemVisible":{},"operDialogVisible":false},"tableRuleDetail":{"title":"规则详情","data":{},"operData":{},"operVisible":{},"operDisabled":{},"disabled":false,"editorForm":true,"itemVisible":{"ruleType":true,"fieldName":true,"keyWord":true,"matchUl":true,"refColumn":true,"resultType":true,"defaultValue":true,"gszd":true},"itemDisabled":{},"transfer":{},"rules":{"ruleType":[{"required":true,"message":"请输入规则类型","trigger":"blur"}]}},"tableTree":{"title":"数据库表","data":[],"filterValue":"","defaultCheckedKeys":[],"currentNodeKey":{},"operData":{"type":""},"operVisible":{"buttonC":true,"buttonQ":true,"type":true},"operDisabled":{},"currentRow":{}},"tableFileds":{"title":"字段信息","currentRow":{},"data":[],"expandRowKeys":[],"pagingData":{},"operData":{},"operVisible":{"buttonA":true,"buttonD":true,"buttonE":true,"C":true},"operDisabled":{},"rawData":[],"itemVisible":{},"operDialogVisible":false},"tableRules":{"title":"处理规则","currentRow":{},"data":[],"expandRowKeys":[],"pagingData":{},"operData":{"type":""},"operVisible":{"type":true,"buttonD":true},"operDisabled":{},"rawData":[],"itemVisible":{},"operDialogVisible":false},"tableInfo":{"title":"基本信息","data":{},"operData":{"type":""},"operVisible":{"type":true,"syncServer":true,"buttonC":true},"operDisabled":{},"disabled":false,"editorForm":true,"itemVisible":{"tableName":true,"remarks":true,"code":true,"categoryCode":true,"orderColumn":true,"selectColumn":true},"itemDisabled":{},"transfer":{},"rules":{"tableName":[{"required":true,"message":"请输入表名","trigger":"blur"}],"code":[{"required":true,"message":"请输入代码标识","trigger":"blur"}]}},"page":{"tabs":"tab1"},"tabDisabled":{"tab1":false,"tab2":false,"tab4":false},"tabVisible":{"tab1":true,"tab2":true,"tab4":true},"customOptions":{},"dictOptions":{},"tableAdd":{"visible":false,"title":"添加表","data":{},"operData":{},"operVisible":{},"operDisabled":{},"disabled":false,"editorForm":true,"itemVisible":{"tableName":true,"remarks":true,"categoryCode":true,"code":true},"itemDisabled":{},"transfer":{},"rules":{"tableName":[{"required":true,"message":"请输入表名","trigger":"blur"}],"remarks":[{"required":true,"message":"请输入中文描述","trigger":"blur"}],"categoryCode":[{"required":true,"message":"请输入归属目录","trigger":"blur"}]}},"tableRefAdd":{"visible":false,"title":"添加子表信息","data":{},"operData":{},"operVisible":{},"operDisabled":{},"disabled":false,"editorForm":true,"itemVisible":{"fkTable":true,"fkField":true,"pkField":true,"deleteRule":true},"itemDisabled":{},"transfer":{},"rules":{"fkTable":[{"required":true,"message":"请输入关联表","trigger":"blur"}],"fkField":[{"required":true,"message":"请输入关联字段","trigger":"blur"}],"pkField":[{"required":true,"message":"请输入主表字段","trigger":"blur"}]}},"tableCategory":{"visible":false,"title":"表目录","data":{},"operData":{},"operVisible":{},"operDisabled":{},"disabled":false,"editorForm":true,"itemVisible":{"code":true,"label":true},"itemDisabled":{},"transfer":{},"rules":{"code":[{"required":true,"message":"请输入目录编码","trigger":"blur"}],"label":[{"required":true,"message":"请输入目录名称","trigger":"blur"}]}},"tableFieldAdd":{"visible":false,"title":"添加字段信息","data":{"type":"VARCHAR","length":255,"scale":0,"isnullable":"Y"},"operData":{},"operVisible":{},"operDisabled":{},"disabled":false,"editorForm":true,"itemVisible":{"name":true,"remarks":true,"type":true,"length":true,"scale":true,"defaultvalue":true,"isnullable":true},"itemDisabled":{},"transfer":{},"rules":{"name":[{"required":true,"message":"请输入字段名称","trigger":"blur"}],"type":[{"required":true,"message":"请输入类型","trigger":"blur"}]}}}
            },
            watch: {
"tableTree.filterValue":function(val){
	this.$refs.tableTree.filter(val);
},
"tableFieldAdd.data.type":function(newVal,oldVal){
    switch(newVal){
        case 'CHAR':
        case 'VARCHAR':
            this.tableFieldAdd.data.scale=0;
            if(this.tableFieldAdd.data.length==0){
                this.tableFieldAdd.data.length=255;
            }
            this.tableFieldAdd.itemDisabled.length=false;
            this.tableFieldAdd.itemDisabled.scale = true;
            break;
        case 'TIMESTAMP':
            this.tableFieldAdd.data.scale=0;
            if(this.tableFieldAdd.data.length==0||this.tableFieldAdd.data.length>6){
                this.tableFieldAdd.data.length=6;
            }
            this.tableFieldAdd.itemDisabled.length=false;
            this.tableFieldAdd.itemDisabled.scale = true;
            break;
        case "DECIMAL":
            this.tableFieldAdd.itemDisabled.length=false;
            this.tableFieldAdd.itemDisabled.scale = false;
            if(this.tableFieldAdd.data.length==0||this.tableFieldAdd.data.length>18){
                this.tableFieldAdd.data.length=10;
            }
            if(this.tableFieldAdd.data.scale==0||this.tableFieldAdd.data.scale>6){
                this.tableFieldAdd.data.length=2;
            }
            break;
        default:
            this.tableFieldAdd.data.length=0;
            this.tableFieldAdd.data.scale=0;
            this.tableFieldAdd.itemDisabled.length=true;
            this.tableFieldAdd.itemDisabled.scale = true;
         
            break;
    }
    
},
"tableRuleDetail.data.ruleType":function(newVal, oldVal) {
    if (newVal == '11' || newVal == '12' || newVal == '32') {
        this.tableRuleDetail.itemVisible.refColumn = true;
    } else {
        this.tableRuleDetail.itemVisible.refColumn = false;
    }

    if (newVal == '32') {
        this.tableRuleDetail.itemVisible.keyWord = true;
    } else {
        this.tableRuleDetail.itemVisible.keyWord = false;
    }

    if (newVal == '11' ||  newVal == '12' || newVal == '13' || newVal == '21' || newVal == '31' || newVal == '41') {
        this.tableRuleDetail.itemVisible.fieldName = true;
    } else {
        this.tableRuleDetail.itemVisible.fieldName = false;
    }


    if (newVal == '12') {
        this.tableRuleDetail.itemVisible.matchUl = true;
    } else {
        this.tableRuleDetail.itemVisible.matchUl = false;
    }


    if (newVal == '41') {
        this.tableRuleDetail.itemVisible.resultType = true;
    } else {
        this.tableRuleDetail.itemVisible.resultType = false;
    }

    if (newVal == '21' || newVal == '31') {
        this.tableRuleDetail.itemVisible.defaultValue = true;
    } else {
        this.tableRuleDetail.itemVisible.defaultValue = false;
    }


    if (newVal == '13') {
        this.tableRuleDetail.itemVisible.gszd = true;
    } else {
        this.tableRuleDetail.itemVisible.gszd = false;
    }


}},
            methods: {
tableAdd_dialogOk:function(){
      let that = this;
      this.$refs.tableAdd.validate(function(valid){
           if(valid){
                that.tableAdd.callback(that.tableAdd.data);
           }else{
                return false;
           }
      });
},
tableRef_change:function(fieldName, row) {
    HttpApi.post("/platform/tableRef/change", row, function() {

    });
},
tableFileds_openTableFieldAdd:function() {
    /*没有定义方法模板，需要去定义方法模板*/
    let that = this;
    let param = {};
    param.tableId = this.tableFileds.operData.tableId;
    this.tableFieldAdd_dialogOpen(param, function(dialogData) {
        HttpApi.post("/platform/tableFields/save", dialogData, function(res) {
             that.tableFileds.data.push(res);
             that.$refs.tableFileds.setCurrentRow(res);
             that.tableFieldAdd.visible = false;
         })
    })
},
tableRules_delete:function() {
    let that = this;
    let id = this.tableRules.currentRow.id;
    if (id) {
        HttpApi.postConfirm("/platform/tableRules/delete", this.tableRules.currentRow, function(res) {
            let index = that.tableRules.data.findIndex(function(item) {
                return item.id == id;
            });
            that.tableRules.data.splice(index, 1);
            if (that.tableRules.data.length == 0) {
                that.$data.tableRules.currentRow = that.$options.data().tableRules.currentRow;
                that.$refs.tableRules.setCurrentRow();
            } else if (that.tableRules.data.length > index) {
                that.$refs.tableRules.setCurrentRow(that.tableRules.data[index]);
            } else {
                that.$refs.tableRules.setCurrentRow(that.tableRules.data[index - 1]);
            }
            that.$message.success("删除成功");
        });
    } else {
        that.$alert("请选择要删除的数据");
    }
},
tableRules_load:function() {
    let that = this;
    HttpApi.post("/platform/tableRules/load", this.tableRules.operData, function(res) {
        that.tableRules.data = res;

        if (that.tableRules.data.length > 0) {
            that.$refs.tableRules.setCurrentRow(that.tableRules.data[0]);
        } else {
            that.$refs.tableRules.setCurrentRow();
        }
    });


    HttpApi.customOptions("tableFields", this.tableRules.operData, function(res) {
        /*请补充方法信息*/
        that.$set(that.customOptions, "tableFields", res);
    });
},
tableRules_currentChange:function(currentRow) {
     if (currentRow) {
        this.tableRules.currentNodeKey = currentRow.id;
        this.tableRules.currentRow = currentRow;
        this.tableRuleDetail.editorForm = true;
        this.tableRuleDetail.data = currentRow;
    } else {
        this.$data.tableRules.currentNodeKey = this.$options.data().tableRules.currentNodeKey;
        this.$data.tableRules.currentRow = this.$options.data().tableRules.currentRow;
        this.tableRuleDetail.editorForm = true;
        this.$data.tableRuleDetail.operData = this.$options.data().tableRuleDetail.operData;
        this.$data.tableRuleDetail.data = this.$options.data().tableRuleDetail.data;
    }
},
tableFileds_delete:function() {
    let that = this;
    let id = this.tableFileds.currentRow.id;
    if (id) {
        HttpApi.postConfirm("/platform/tableFields/delete", this.tableFileds.currentRow, function(res) {
            let index = that.tableFileds.data.findIndex(function(item) {
                return item.id == id;
            });
            that.tableFileds.data.splice(index, 1);
            if (that.tableFileds.data.length == 0) {
                that.$data.tableFileds.currentRow = that.$options.data().tableFileds.currentRow;
                that.$refs.tableFileds.setCurrentRow();
            } else if (that.tableFileds.data.length > index) {
                that.$refs.tableFileds.setCurrentRow(that.tableFileds.data[index]);
            } else {
                that.$refs.tableFileds.setCurrentRow(that.tableFileds.data[index - 1]);
            }
            that.$message.success("删除成功");
        });
    } else {
        that.$alert("请选择要删除的数据");
    }
},
tableFieldAdd_dialogOpen:function(param,callback){
    this.$data.tableFieldAdd.data = this.$options.data().tableFieldAdd.data;
    this.$data.tableFieldAdd.operData = this.$options.data().tableFieldAdd.operData;
    for(let val in param) {
        this.$set(this.tableFieldAdd.data, val, param[val])
    }
    this.tableFieldAdd.callback=callback;
    this.tableFieldAdd.visible = true;
}
,
tableFieldAdd_dialogOk:function(){
      let that = this;
      this.$refs.tableFieldAdd.validate(function(valid){
           if(valid){
                that.tableFieldAdd.callback(that.tableFieldAdd.data);
           }else{
                return false;
           }
      });
},
tableRef_operCtrl:function(currentRow) {
    /**
    * operDisabled：控制按钮的是否禁止操作，true代表禁止操作，false代表允许操作
    * this.$set(this.stdSolReceiveHistory.operDisabled, "buttonE", true);
    * operVisible：控制按钮是否显示，true代表显示，false代表不显示
    * this.$set(this.stdSolReceiveHistory.operVisible, "buttonE", false);
    */
    if(!currentRow) {
       this.$set(this.tableRef.operDisabled, "buttonD", true);//删除(D)

    }else {
       this.$set(this.tableRef.operDisabled, "buttonD", false);//删除(D)

    }
},
tableTree_allowDrop:function(draggingNode, dropNode, type){
    /*拖拽时判定目标节点能否被放置。
    type ：'prev'、'inner' 和 'next'，
    分别表示放置在目标节点前、插入至目标节点和放置在目标节点后*/
    if(dropNode.data.type=='category' && type=='inner'){
        return true;
    }else{
        return false;
    }
},
tableTree_nodeDrop:function(draggingNode, dropNode, dropType, ev) {
    //共四个参数，依次为：被拖拽节点对应的 Node、结束拖拽时最后进入的节点、被拖拽节点的放置位置（before、after、inner）、event
    let that = this;
    draggingNode.data.parentId = dropNode.data.id;
    draggingNode.data.categoryCode = dropNode.data.code;
    HttpApi.post("/platform/tableTree/nodeDrop", draggingNode.data, function(res) {
        /*请补充方法信息*/
        that.$message.success("拖拽成功");
    });
},
tableFileds_change:function(fieldName, row) {
    HttpApi.post("/platform/tableFields/change/" + fieldName, row, function() {

    });
},
tableRef_delete:function() {
    let that = this;
    let id = this.tableRef.currentRow.id;
    if (id) {
        HttpApi.postConfirm("/platform/tableRef/delete", this.tableRef.currentRow, function(res) {
            let index = that.tableRef.data.findIndex(function(item) {
                return item.id == id;
            });
            that.tableRef.data.splice(index, 1);
            if (that.tableRef.data.length == 0) {
                that.$data.tableRef.currentRow = that.$options.data().tableRef.currentRow;
                that.$refs.tableRef.setCurrentRow();
            } else if (that.tableRef.data.length > index) {
                that.$refs.tableRef.setCurrentRow(that.tableRef.data[index]);
            } else {
                that.$refs.tableRef.setCurrentRow(that.tableRef.data[index - 1]);
            }
            that.$message.success("删除成功");
        });
    } else {
        that.$alert("请选择要删除的数据");
    }
},
tableFileds_load:function() {
    let that = this;
    HttpApi.post("/platform/tableFields/load", this.tableFileds.operData, function(res) {
        that.tableFileds.data = res;
        if (res.length > 0) {
            that.$refs.tableFileds.setCurrentRow(res[0]);
        }
    });
},
tableFieldAdd_load:function(){
    let that = this;
    HttpApi.queryObject("",this.tableFieldAdd.operData,function(res){
        that.tableFieldAdd.data = res;
    });
},
tableRefAdd_queryPkFields:function() {
    let that = this;
    let param = {};
    param.tableId = this.tableRefAdd.data.tableId;
    HttpApi.post("/platform/tableRefAdd/queryPkFields", param, function(res) {
        /*请补充方法信息*/
        that.$set(that.customOptions, "pkField", res);
    });
},
tableRefAdd_dialogOk:function(){
      let that = this;
      this.$refs.tableRefAdd.validate(function(valid){
           if(valid){
                that.tableRefAdd.callback(that.tableRefAdd.data);
           }else{
                return false;
           }
      });
},
tableCategory_dialogCancel:function(){
     this.tableCategory.visible = false;
},
tableRef_load:function() {
    let that = this;
    HttpApi.post("/platform/tableRef/load", this.tableRef.operData, function(res) {
        that.tableRef.data = res;

        if (that.tableRef.data.length > 0) {
            that.$refs.tableRef.setCurrentRow(that.tableRef.data[0]);
        }

    });
},
tableInfo_syncFromServer:function(param) {

    let that = this;
    HttpApi.post("/platform/tableTree/syncFromServer", this.tableInfo.data, function(res) {
        /*请补充方法信息*/
        that.$message.success("同步成功");
    });
},
tableRefAdd_dialogCancel:function(){
     this.tableRefAdd.visible = false;
},
tableAdd_dialogOpen:function(param, callback) {
    this.$data.tableAdd.data = this.$options.data().tableAdd.data;
    this.$data.tableAdd.operData = this.$options.data().tableAdd.operData;
    for (let val in param) {
        this.$set(this.tableAdd.data, val, param[val])
    }
    this.tableAdd.callback = callback;
    this.tableAdd.visible = true;
},
tableRules_operCtrl:function(currentRow) {
    /**
    * operDisabled：控制按钮的是否禁止操作，true代表禁止操作，false代表允许操作
    * this.$set(this.stdSolReceiveHistory.operDisabled, "buttonE", true);
    * operVisible：控制按钮是否显示，true代表显示，false代表不显示
    * this.$set(this.stdSolReceiveHistory.operVisible, "buttonE", false);
    */
    if(!currentRow) {
       this.$set(this.tableRules.operDisabled, "buttonD", true);//删除(D)

    }else {
       this.$set(this.tableRules.operDisabled, "buttonD", false);//删除(D)

    }
},
tableFileds_currentChange:function(currentRow){
    if(currentRow){
        this.tableFileds.currentNodeKey=currentRow.id;
        this.tableFileds.currentRow = currentRow;
        
    }else{
        this.$data.tableFileds.currentNodeKey=this.$options.data().tableFileds.currentNodeKey;
        this.$data.tableFileds.currentRow = this.$options.data().tableFileds.currentRow;
        
    }
    this.tableFileds_operCtrl(currentRow);
},
tableRef_openTableRefAdd:function() {
    let that = this;
    this.tableRefAdd.editorForm = false;
    let param = {};
    param.tableId = this.tableRef.operData.tableId;
    this.tableRefAdd_dialogOpen(param, function(dialogData) {
        HttpApi.post("/platform/tableRef/save", dialogData, function(res) {
            that.tableRef.data.push(res);
            that.$refs.tableRef.setCurrentRow(res);
            that.tableRefAdd.visible = false;
        });
    })
},
tableTree_treeCommand:function(param) {
    let that = this;

    if (param.flag == 'editCategory') {
        that.tableCategory.editorForm = true;
        that.tableCategory_dialogOpen(param.nodeData, function(dialogData) {
            HttpApi.post("/platform/tableTree/addCategory", dialogData, function(res) {
                that.tableTree.data.forEach(function(item, index) {
                    if (item.id == res.id) {
                        that.$set(item, "label", res.label);
                        that.$set(item, "code", res.code);
                    }
                });
                that.tableCategory.visible = false;
            });
        })
    }

    if (param.flag == 'delCategory') {
        that.tableCategory.editorForm = true;
        HttpApi.postConfirm("/platform/tableTree/delCategory", param.nodeData, function(res) {
            that.$refs.tableTree.remove(param.nodeData);
            HttpApi.customOptions("tableCategory", {}, function(res) {
                that.$set(that.customOptions, "tableCategory", res);
            });
        });
    }

    if (param.flag == 'syncFromDb') {
        HttpApi.post("/platform/tableTree/syncFromDb", param.nodeData, function(res) {
            /*请补充方法信息*/
            that.$message.success("同步成功");
        });
    }

    if (param.flag == 'delTable') {
        HttpApi.postConfirm("/platform/tableTree/delTable", param.nodeData, function(res) {
            that.$refs.tableTree.remove(param.nodeData);
            /*请补充方法信息*/
            that.$message.success("删除成功");
        });
    }
},
tableInfo_change:function(fieldName) {
    HttpApi.post("/platform/tableInfo/change/" + fieldName, this.tableInfo.data, function() {

    });
},
tableFileds_operCtrl:function(currentRow) {
    /**
    * operDisabled：控制按钮的是否禁止操作，true代表禁止操作，false代表允许操作
    * this.$set(this.stdSolReceiveHistory.operDisabled, "buttonE", true);
    * operVisible：控制按钮是否显示，true代表显示，false代表不显示
    * this.$set(this.stdSolReceiveHistory.operVisible, "buttonE", false);
    */
    if(!currentRow) {
       this.$set(this.tableFileds.operDisabled, "buttonD", true);//删除(D)
this.$set(this.tableFileds.operDisabled, "buttonE", true);//编辑(E)

    }else {
       this.$set(this.tableFileds.operDisabled, "buttonD", false);//删除(D)
this.$set(this.tableFileds.operDisabled, "buttonE", false);//编辑(E)

    }
},
tableFieldAdd_dialogCancel:function(){
     this.tableFieldAdd.visible = false;
},
tableTree_load:function() {
    let that = this;
    HttpApi.post("/platform/tableTree/load", this.tableTree.operData, function(res) {
        that.tableTree.data = res;
        if (res.length > 0) {
            that.$nextTick(function() {
                that.$refs.tableTree.setCurrentKey(res[0].id);
                that.tableTree_currentChange(res[0]);
            });
        } else {
            that.tableTree_currentChange();
        }
    });
},
tableRefAdd_queryFkFields:function(fkTable) {
    let that = this;
    let param = {};
    param.tableId = this.tableRefAdd.data.tableId;
    param.fkTable = fkTable;
    HttpApi.post("/platform/tableRefAdd/queryFkFields", param, function(res) {
        /*请补充方法信息*/
        that.$set(that.customOptions, "fkField", res);
    });
},
tableTree_currentChange:function(data, node) {
    if (data) {
        this.tableTree.currentNodeKey = data.id;
        this.tableTree.currentRow = data;
        this.tableInfo.editorForm = true;
        this.tableInfo.operData.id = this.tableTree.currentRow.id;
        this.tableInfo_load();

        this.tableFileds.operData.tableId = data.id;
        this.tableFileds_load();

        this.tableRef.operData.tableId = data.id;
        this.tableRef_load();

        this.tableRules.operData.tableId = data.id;
        this.tableRules_load();

    } else {
        this.$data.tableTree.currentNodeKey = this.$options.data().tableTree.currentNodeKey;
        this.$data.tableTree.currentRow = this.$options.data().tableTree.currentRow;
        this.$data.tableInfo.operData = this.$options.data().tableInfo.operData;
        this.$data.tableInfo.data = this.$options.data().tableInfo.data;

        this.$data.tableFileds.operData = this.$options.data().tableFileds.operData;
        this.$data.tableFileds.data = this.$options.data().tableFileds.data;

        this.$data.tableRef.operData = this.$options.data().tableRef.operData;
        this.$data.tableRef.data = this.$options.data().tableRef.data;

        this.$data.tableRules.operData = this.$options.data().tableRules.operData;
        this.$data.tableRules.data = this.$options.data().tableRules.data;

    }
},
tableRules_queryFields:function(){
     let that = this;
     
}
,
tableInfo_syncToServer:function(param) {
    let that = this;
    HttpApi.post("/platform/tableInfo/syncToServer", this.tableInfo.data, function(res) {
        /*请补充方法信息*/
        that.$message.success("同步成功");
    });
},
tableRefAdd_dialogOpen:function(param,callback){
    this.$data.tableRefAdd.data = this.$options.data().tableRefAdd.data;
    this.$data.tableRefAdd.operData = this.$options.data().tableRefAdd.operData;
    for(let val in param) {
        this.$set(this.tableRefAdd.data, val, param[val])
    }
    this.tableRefAdd.callback=callback;
    this.tableRefAdd.visible = true;
    //数据加载
    this.tableRefAdd_queryPkFields();
    this.tableRefAdd_queryAcTables();
    
}
,
tableRuleDetail_change:function(fieldName) {
    if (fieldName == "keyWord") {
        this.$set(this.tableRuleDetail.data, "fieldName", this.tableRuleDetail.data.keyWord);
    }

    HttpApi.post("/platform/tableRuleDetail/change/" + fieldName, this.tableRuleDetail.data, function() {

    });
},
tableAdd_load:function() {
    let that = this;
    HttpApi.post("/platform/tableAdd/load", this.tableAdd.operData, function(res) {
        that.tableAdd.data = res;
    });
},
tableTree_command:function(param) {
    let that = this;
    if (param.type == 'addCategory') {
        that.tableCategory.editorForm = false;
        that.tableCategory_dialogOpen({}, function(dialogData) {
            HttpApi.post("/platform/tableTree/addCategory", dialogData, function(res) {
                that.tableTree.data.push(res);
                that.tableCategory.visible = false;
                HttpApi.customOptions("tableCategory", {}, function(res) {
                    that.$set(that.customOptions, "tableCategory", res);
                });
            });
        })
    }

    if (param.type == 'addTable') {
        that.tableAdd.editorForm = false;
        that.tableAdd_dialogOpen({}, function(dialogData) {
            HttpApi.post("/platform/tableTree/addTable", dialogData, function(res) {
                that.$refs.tableTree.append(res, res.categoryCode);
                that.tableAdd.visible = false;
            });
        })
    }


    if (param.type == 'syncFromDb') {
        HttpApi.post("/platform/tableTree/syncFromDb", {}, function(res) {
            /*请补充方法信息*/
            that.$message.success("同步成功");
        });
    }


    if (param.type == 'syncFromServer') {
        this.tableTree_syncFromServer();
    }


},
tableTree_allowDrag:function(node){
    if(node.data.type=='table'){
        return true;
    }else{
        return false;
    }
},
tableInfo_load:function() {
    let that = this;
    HttpApi.post("/platform/tableInfo/load", this.tableInfo.operData, function(res) {
        that.tableInfo.data = res;
    });
},
tableTree_check:function(node,list){
	/*设置单选
	if (list.checkedKeys.length >= 2) {
		this.$ref.tableTree.setCheckedKeys([node.id]);
	}*/
},
tableAdd_dialogCancel:function(){
     this.tableAdd.visible = false;
},
tableFileds_sort:function() {
    let that = this;
    let param = {};
    param.tableId = this.tableFileds.operData.tableId;

    HttpApi.postConfirm("/platform/tableFields/sort", param, function(res) {
        //请补充方法执行成功后要做的操作
        that.tableFileds.data = res;
        if (res.length > 0) {
            that.$refs.tableFileds.setCurrentRow(res[0]);
        }
        that.$message.success("执行成功！");
    })
},
tableRules_addYsRule:function(param) {
    let that = this;
    param.tableId = this.tableRules.operData.tableId;
    HttpApi.post("/platform/tableRules/addYsRule", param, function(res) {
        /*请补充方法信息*/
        that.tableRules.data.push(res);
    });
},
tableFileds_editTableFieldAdd:function() {
    /*没有定义方法模板，需要去定义方法模板*/
    let that = this;

    this.tableFieldAdd.editorForm = true;

    if (!that.tableFileds.currentRow.id) {
        that.$alert("请先选中一条字段信息信息");
        return;
    } else {
        that.tableFieldAdd_dialogOpen(that.tableFileds.currentRow, function(dialogData) {
            HttpApi.post("/platform/tableFields/save", dialogData, function(res) {
                let index = that.tableFileds.data.findIndex(function(item) {
                    return item.id == res.id;
                });
                that.$set(that.tableFileds.data, index, res);
                that.$refs.tableFileds.setCurrentRow(res);
                that.tableFieldAdd.visible = false;
            });
        })
    }
},
tableRuleDetail_load:function() {
    let that = this;
    HttpApi.post("/platform/tableRuleDetail/load", this.tableRuleDetail.operData, function(res) {
        that.tableRuleDetail.data = res;
    });
},
tableCategory_dialogOpen:function(param,callback){
    this.$data.tableCategory.data = this.$options.data().tableCategory.data;
    this.$data.tableCategory.operData = this.$options.data().tableCategory.operData;
    for(let val in param) {
        this.$set(this.tableCategory.data, val, param[val])
    }
    this.tableCategory.callback=callback;
    this.tableCategory.visible = true;
}
,
tableRefAdd_queryAcTables:function(param) {
    let that = this;
    HttpApi.post("/platform/tableRefAdd/queryAcTables", {}, function(res) {
        /*请补充方法信息*/
        that.$set(that.customOptions, "fkTable", res);
    });
},
tableRefAdd_load:function() {
    let that = this;
    HttpApi.post("/platform/tableRefAdd/load", this.tableRefAdd.operData, function(res) {
        that.tableRefAdd.data = res;
    });
},
tableCategory_dialogOk:function(){
      let that = this;
      this.$refs.tableCategory.validate(function(valid){
           if(valid){
                that.tableCategory.callback(that.tableCategory.data);
           }else{
                return false;
           }
      });
},
tableTree_filterNodeMethod:function(value, data) {
    if (!value) return true;
    if (data.type == 'category') {
        return data.label.indexOf(value.toLowerCase()) !== -1
    } else {
        return data.tableName.indexOf(value.toLowerCase()) !== -1;
    }

},
tableRef_currentChange:function(currentRow){
    if(!currentRow){
        //如果没有传入值，则将当前的选中值清空
        this.$data.tableRef.currentRow = this.$options.data().tableRef.currentRow;
    }else{
        this.tableRef.currentRow = currentRow;
    }
},
tableCategory_load:function() {
    let that = this;
    HttpApi.post("/platform/tableCategory/load", this.tableCategory.operData, function(res) {
        that.tableCategory.data = res;
    });
},
tableTree_syncFromServer:function(param) {
    let that = this;
    HttpApi.post("/platform/tableTree/syncFromServer", {}, function(res) {
        /*请补充方法信息*/
        that.$message.success("同步成功");
    });
},
tableRefAdd_change:function(fieldName){
    if (fieldName=='fkTable') {
        this.tableRefAdd_queryFkFields(this.tableRefAdd.data.fkTable);
    }
}
},
            mounted: function(){
    dragControllerLR();
    dragControllerUD();
},
            created: function() {
    let that = this;
    //获取字典信息
    HttpApi.dictOptions([], function(res) {
        that.dictOptions = res;
    });

    //加载自定义数据字典
    HttpApi.customOptions("tableFields", {}, function(res) {
        that.$set(that.customOptions, "tableFields", res);
    });
    HttpApi.customOptions("tableCategory", {}, function(res) {
        that.$set(that.customOptions, "tableCategory", res);
    });
    HttpApi.customOptions("fkTable", {}, function(res) {
        that.$set(that.customOptions, "fkTable", res);
    });
    HttpApi.customOptions("fkField", {}, function(res) {
        that.$set(that.customOptions, "fkField", res);
    });
    HttpApi.customOptions("pkField", {}, function(res) {
        that.$set(that.customOptions, "pkField", res);
    });


    //加载初始化load
    this.tableTree_load();

    //加载初始化方法

}
    });
    

    
</script>
</html>
